package com.nuliji.util.shiro;

import org.apache.commons.lang3.time.FastDateFormat;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

/**
 * Created by GaoJie on 2017/11/3.
 */
public class OauthRealm extends AuthorizingRealm {
    private static final FastDateFormat dateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
        return null;
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        String code = token.getUsername();
        String platform = new String(token.getPassword());

        // todo 查询第三方登录
//        switch(platform){
//
//            default:
//                throw new ParameterException("第三方平台"+platform+"不支持");
//        }


        return new SimpleAuthenticationInfo(token, code, getName());
    }
}
